<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>nBuy管理平台</title>
<link rel="stylesheet" type="text/css" href="${ctx}/res/css/default.css">
<link rel="stylesheet" type="text/css" href="${ctx}/res/css/easyui.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/res/css/icon.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/res/css/style.css">
<script type="text/javascript" src="${ctx}/res/js/jquery.min.js"></script>
<script type="text/javascript" src="${ctx}/res/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/res/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/res/js/menu.js"></script>
<script type="text/javascript" src="${ctx}/res/js/index.js"></script>
<script type="text/javascript" src="${ctx}/res/js/base.js"></script>
<script type="text/javascript">
	var _menus = {
		"menus" : [ {
			"menuid" : "1",
			"icon" : "icon-sys",
			"menuname" : "客户管理",
			"menus" : [ {
				"menuname" : "管理客户资料",
				"icon" : "icon-nav",
				"url" : "${ctx}/customer/customer"
			}, {
				"menuname" : "客户资料检索",
				"icon" : "icon-nav",
				"url" : "${ctx}/customer/customerRsetrieval"
			} ]
		}, {
			"menuid" : "2",
			"icon" : "icon-sys",
			"menuname" : "商品管理",
			"menus" : [ {
				"menuname" : "管理商品信息",
				"icon" : "icon-nav",
				"url" : "${ctx}/product/product"
			}, {
				"menuname" : "商品信息检索",
				"icon" : "icon-add",
				"url" : "${ctx}/product/productRsetrieval"
			} ]
		}, {
			"menuid" : "3",
			"icon" : "icon-sys",
			"menuname" : "订单管理",
			"menus" : [ {
				"menuname" : "订单维护",
				"icon" : "icon-nav",
				"url" : "${ctx}/order/order"
			}, {
				"menuname" : "订单查询",
				"icon" : "icon-add",
				"url" : "${ctx}/order/orderRsetrieval"
			} ]
		}, {
			"menuid" : "4",
			"icon" : "icon-sys",
			"menuname" : "商品分类管理",
			"menus" : [ {
				"menuname" : "商品分类维护",
				"icon" : "icon-nav",
				"url" : "${ctx}/mainType/mainType"
			} ]
		}, {
			"menuid" : "5",
			"icon" : "icon-sys",
			"menuname" : "公告管理",
			"menus" : [ {
				"menuname" : "公告维护",
				"icon" : "icon-nav",
				"url" : "${ctx}/notice/notice"
			} ]
		},{
			"menuid" : "6",
			"icon" : "icon-sys",
			"menuname" : "管理员管理",
			"menus" : [ {
				"menuname" : "管理员资料",
				"icon" : "icon-nav",
				"url" : "${ctx}/administrator/administrator"
			} ]
		} ]
	};

	//设置修改密码窗口
	function openPwd() {
		$('#w').window({
			title : '修改密码',
			width : 300,
			modal : false,
			shadow : false,
			closed : true,
			height : 200,
			resizable : false
		});
	}
	//关闭修改密码窗口
	function closePwd() {
		$('#w').window('close');
	}

	//修改密码
	function changePwd() {
		var $oldPwd = $('#txtOldPwd');
		var $newPwd = $('#txtNewPwd');
		var $rePwd = $('#txtRePwd');
		
		if ($oldPwd.val() == '') {
			msgShow('系统提示', '请输入原密码！', 'warning');
			return false;
		}
		if ($newPwd.val() == '') {
			msgShow('系统提示', '请输入新密码！', 'warning');
			return false;
		}
		if ($rePwd.val() == '') {
			msgShow('系统提示', '请再输入新密码！', 'warning');
			return false;
		}

		if ($newPwd.val() != $rePwd.val()) {
			msgShow('系统提示', '两次输入新密码不一致，请重新输入！', 'warning');
			return false;
		}
		
		//获取到要传递的参数，并且构造Json。
        var postData = {
            oldPwd: $oldPwd.val(),
            newPwd: $newPwd.val(),
            rePwd: $rePwd.val()
        };

        //发送异步请求实现密码修改 ajax
        $.ajax({
            url: '${ctx}/changePwd',
            data: postData,
            cache: false,
            async: true,
            type: 'post',
            success: function (data) {
				if (data.result) {
	                msgShow('系统提示', '密码修改成功！', 'info');
	       			$oldPwd.val('');
	       			$newPwd.val('');
	       			$rePwd.val('');
	       			closePwd();
				} else {
					$error(data.msg);
				}
            }
        });
	}

	$(function() {
		openPwd();
		
		$('#editpass').click(function() {
			$('#w').window('open');
		});

		$('#btnEp').click(function() {
			changePwd();
		})
		
		$('#btnClosePwd').click(function() {
			closePwd();
		})

		$('#logout').click(function() {
			$.messager.confirm('系统提示', '您确定要退出本次登录吗?', function(r) {
				if (r) {
					location.href = '${ctx}/admin/logout';
				}
			});
		})
		
		var myDate = new Date();
		var msg = myDate.getFullYear() + "年" + (myDate.getMonth() + 1) + "月" + myDate.getDate() + "日";
		$("#date").html(msg);
	});
</script>
</head>
<body class="easyui-layout" style="overflow-y: hidden; scroll: no">
	<div data-options="region:'north',border:false" id="header" style="overflow-y: hidden; height: 80px; scroll: no">
		<ul class="button">
			<li><font style="color: red; size: 25">${sessionScope.sessionlogin}</font>，您好！ <br/>当前日期：<b id="date"></b>&nbsp;&nbsp;&nbsp;&nbsp;
			</li>
			<li><a href="#" id="editpass" title="修改密码"><img border="0"
					src="${ctx}/res/img/btn_hd_support.gif" title="修改密码"
					alt="修改密码" /> </a></li>
			<li><a href="#" id="logout" title="安全退出"><b><img
						border="0" src="${ctx}/res/img/btn_hd_exit.gif" title="安全退出"
						alt="安全退出" /></b></a></li>
		</ul>
	</div>
	<div data-options="region:'west',split:true,title:'导航菜单'"
		style="width: 180px;" id="west">
		<div id="accordion">
			<!--  导航内容 -->
		</div>
	</div>
	<div id="mainPanle" region="center"
		style="background: #eee; overflow-y: hidden">
		<div id="tabs" class="easyui-tabs" fit="true" border="false" cache="false">
			<div title="系统首页" style="padding: 20px; overflow: hidden;" id="home">
				<h1>欢迎使用nBuy管理平台</h1>			
			</div>
		</div>
	</div>
	<div data-options="region:'south',border:false"
		style="height: 30px; background: #D2E0F2;">
		<div class="easyui-layout" data-options="fit:true"
			style="background: #209de4; text-align: center; color: #15428B; font-weight: bold; padding-top: 10px;">
			nBuy<a href="mailto:"></a>
		</div>
	</div>
	
	<!--修改密码窗口-->
	<div id="w" class="easyui-dialog" title="修改密码" collapsible="false"
		minimizable="false" maximizable="false" icon="icon-save"
		style="width: 300px; height: 200px; padding: 5px; background: #fafafa;">
		<div class="easyui-layout" fit="true">
			<div region="center" border="false"
				style="padding: 10px; background: #fff; border: 1px solid #ccc;">
				<table cellpadding=3>
					<tr>
						<td>原密码：</td>
						<td><input id="txtOldPwd" type="password" class="txt01" /></td>
					</tr>
					<tr>
						<td>新密码：</td>
						<td><input id="txtNewPwd" type="password" class="txt01" /></td>
					</tr>
					<tr>
						<td>确认密码：</td>
						<td><input id="txtRePwd" type="password" class="txt01" /></td>
					</tr>
				</table>
			</div>
			<div region="south" border="false"
				style="text-align: right; height: 30px; line-height: 25px;">
				<a id="btnEp" class="easyui-linkbutton" icon="icon-ok"
					href="javascript:void(0)"> 确定</a> <a id="btnClosePwd" class="easyui-linkbutton"
					icon="icon-cancel" href="javascript:void(0)">取消</a>
			</div>
		</div>
	</div>
	<!--tab右键操作-->
	<div id="mm" class="easyui-menu" style="width: 150px;">
		<div id="mm-tabclose">关闭</div>
		<div id="mm-tabcloseall">全部关闭</div>
		<div id="mm-tabcloseother">除此之外全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-tabcloseright">当前页右侧全部关闭</div>
		<div id="mm-tabcloseleft">当前页左侧全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-exit">退出</div>
	</div>
</body>
</html>